<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>arduino-audio-driver: src/Utils/Optional.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">arduino-audio-driver
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_a7363e98f9e0bdd87618633653859815.html">Utils</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Optional.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_optional_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160; </div>
<div class="line"><a name="l00003"></a><span class="lineno"><a class="line" href="namespaceaudio__driver__local.html">    3</a></span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceaudio__driver__local.html">audio_driver_local</a> {</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno"><a class="line" href="classaudio__driver__local_1_1_optional.html">   10</a></span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; <span class="keyword">class </span><a class="code" href="classaudio__driver__local_1_1_optional.html">Optional</a> {</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00012"></a><span class="lineno"><a class="line" href="classaudio__driver__local_1_1_optional.html#a8abdf29c53e2d866ae58f1550b479120">   12</a></span>&#160;  <a class="code" href="classaudio__driver__local_1_1_optional.html#a8abdf29c53e2d866ae58f1550b479120">Optional</a>() {}</div>
<div class="line"><a name="l00013"></a><span class="lineno"><a class="line" href="classaudio__driver__local_1_1_optional.html#a83e27dc44351c7b10e39d6fcfc9711e6">   13</a></span>&#160;  <a class="code" href="classaudio__driver__local_1_1_optional.html#a83e27dc44351c7b10e39d6fcfc9711e6">Optional</a>(T <a class="code" href="classaudio__driver__local_1_1_optional.html#a464298ad7afeafebbb149f566ecabbab">value</a>) {</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    <a class="code" href="classaudio__driver__local_1_1_optional.html#a31844d8ef66fe7930f88cc30cf53d08c">val</a> = <a class="code" href="classaudio__driver__local_1_1_optional.html#a464298ad7afeafebbb149f566ecabbab">value</a>;</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;    <a class="code" href="classaudio__driver__local_1_1_optional.html#a7b1d0df736739f38994ed29f54cffdf3">is_valid</a> = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;  }</div>
<div class="line"><a name="l00017"></a><span class="lineno"><a class="line" href="classaudio__driver__local_1_1_optional.html#a67b76affb3b5d35fa419ac234144038b">   17</a></span>&#160;  <span class="keyword">operator</span> bool()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classaudio__driver__local_1_1_optional.html#a7b1d0df736739f38994ed29f54cffdf3">is_valid</a>; }</div>
<div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="classaudio__driver__local_1_1_optional.html#a464298ad7afeafebbb149f566ecabbab">   18</a></span>&#160;  T &amp;<a class="code" href="classaudio__driver__local_1_1_optional.html#a464298ad7afeafebbb149f566ecabbab">value</a>() { <span class="keywordflow">return</span> <a class="code" href="classaudio__driver__local_1_1_optional.html#a31844d8ef66fe7930f88cc30cf53d08c">val</a>; }</div>
<div class="line"><a name="l00019"></a><span class="lineno"><a class="line" href="classaudio__driver__local_1_1_optional.html#ac79ae016f6483a4b7510d4f621c167c8">   19</a></span>&#160;  T &amp;<a class="code" href="classaudio__driver__local_1_1_optional.html#ac79ae016f6483a4b7510d4f621c167c8">valueOr</a>(T alt) { <span class="keywordflow">return</span> <a class="code" href="classaudio__driver__local_1_1_optional.html#a7b1d0df736739f38994ed29f54cffdf3">is_valid</a> ? <a class="code" href="classaudio__driver__local_1_1_optional.html#a31844d8ef66fe7930f88cc30cf53d08c">val</a> : alt; }</div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="classaudio__driver__local_1_1_optional.html#ad20897c5c8bd47f5d4005989bead0e55">   20</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classaudio__driver__local_1_1_optional.html#ad20897c5c8bd47f5d4005989bead0e55">reset</a>() { <a class="code" href="classaudio__driver__local_1_1_optional.html#a7b1d0df736739f38994ed29f54cffdf3">is_valid</a> = <span class="keyword">false</span>; }</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160; </div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00023"></a><span class="lineno"><a class="line" href="classaudio__driver__local_1_1_optional.html#a7b1d0df736739f38994ed29f54cffdf3">   23</a></span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classaudio__driver__local_1_1_optional.html#a7b1d0df736739f38994ed29f54cffdf3">is_valid</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="classaudio__driver__local_1_1_optional.html#a31844d8ef66fe7930f88cc30cf53d08c">   24</a></span>&#160;  T <a class="code" href="classaudio__driver__local_1_1_optional.html#a31844d8ef66fe7930f88cc30cf53d08c">val</a>;</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;};</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160; </div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;}</div>
<div class="ttc" id="aclassaudio__driver__local_1_1_optional_html"><div class="ttname"><a href="classaudio__driver__local_1_1_optional.html">audio_driver_local::Optional</a></div><div class="ttdoc">A simple optonal implementation.</div><div class="ttdef"><b>Definition:</b> Optional.h:10</div></div>
<div class="ttc" id="aclassaudio__driver__local_1_1_optional_html_a31844d8ef66fe7930f88cc30cf53d08c"><div class="ttname"><a href="classaudio__driver__local_1_1_optional.html#a31844d8ef66fe7930f88cc30cf53d08c">audio_driver_local::Optional::val</a></div><div class="ttdeci">T val</div><div class="ttdef"><b>Definition:</b> Optional.h:24</div></div>
<div class="ttc" id="aclassaudio__driver__local_1_1_optional_html_a464298ad7afeafebbb149f566ecabbab"><div class="ttname"><a href="classaudio__driver__local_1_1_optional.html#a464298ad7afeafebbb149f566ecabbab">audio_driver_local::Optional::value</a></div><div class="ttdeci">T &amp; value()</div><div class="ttdef"><b>Definition:</b> Optional.h:18</div></div>
<div class="ttc" id="aclassaudio__driver__local_1_1_optional_html_a7b1d0df736739f38994ed29f54cffdf3"><div class="ttname"><a href="classaudio__driver__local_1_1_optional.html#a7b1d0df736739f38994ed29f54cffdf3">audio_driver_local::Optional::is_valid</a></div><div class="ttdeci">bool is_valid</div><div class="ttdef"><b>Definition:</b> Optional.h:23</div></div>
<div class="ttc" id="aclassaudio__driver__local_1_1_optional_html_a83e27dc44351c7b10e39d6fcfc9711e6"><div class="ttname"><a href="classaudio__driver__local_1_1_optional.html#a83e27dc44351c7b10e39d6fcfc9711e6">audio_driver_local::Optional::Optional</a></div><div class="ttdeci">Optional(T value)</div><div class="ttdef"><b>Definition:</b> Optional.h:13</div></div>
<div class="ttc" id="aclassaudio__driver__local_1_1_optional_html_a8abdf29c53e2d866ae58f1550b479120"><div class="ttname"><a href="classaudio__driver__local_1_1_optional.html#a8abdf29c53e2d866ae58f1550b479120">audio_driver_local::Optional::Optional</a></div><div class="ttdeci">Optional()</div><div class="ttdef"><b>Definition:</b> Optional.h:12</div></div>
<div class="ttc" id="aclassaudio__driver__local_1_1_optional_html_ac79ae016f6483a4b7510d4f621c167c8"><div class="ttname"><a href="classaudio__driver__local_1_1_optional.html#ac79ae016f6483a4b7510d4f621c167c8">audio_driver_local::Optional::valueOr</a></div><div class="ttdeci">T &amp; valueOr(T alt)</div><div class="ttdef"><b>Definition:</b> Optional.h:19</div></div>
<div class="ttc" id="aclassaudio__driver__local_1_1_optional_html_ad20897c5c8bd47f5d4005989bead0e55"><div class="ttname"><a href="classaudio__driver__local_1_1_optional.html#ad20897c5c8bd47f5d4005989bead0e55">audio_driver_local::Optional::reset</a></div><div class="ttdeci">void reset()</div><div class="ttdef"><b>Definition:</b> Optional.h:20</div></div>
<div class="ttc" id="anamespaceaudio__driver__local_html"><div class="ttname"><a href="namespaceaudio__driver__local.html">audio_driver_local</a></div><div class="ttdef"><b>Definition:</b> Optional.h:3</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
